package com.itheima.ArrayList;

import com.itheima.ArrayList.domain.Student;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.Scanner;

public class Demo03ArrayList {
    public static void main(String[] args) {
        ArrayList<Student> list=new ArrayList<>();

        for (int i = 0; i <3 ; i++) {

            list.add(Method(i+1));
        }
        for (int i = 0; i <3 ; i++) {

            System.out.println(list.get(i).getName()+list.get(i).getAge());
        }
    }

    private static Student Method(int count) {
        Scanner sc=new Scanner(System.in);
        System.out.println("请输入"+count+"姓名:");
        String name = sc.next();
        System.out.println("请输入"+count+"年龄:");
        int age = sc.nextInt();

        Student student=new Student(name,age);

        return student;
    }


}
